package com.xoa.controller.attendance.attendanceSetting;

import com.xoa.model.attendance.AttendRule;
import com.xoa.service.attend.AttendService;
import com.xoa.service.attendance.rule.AttendRuleService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/attendRule")
public class AttendRuleController {

    @Autowired
    private AttendRuleService attendRuleService;

    /**
     * 去往统计规则设置页面映射
     * @return
     */
    @RequestMapping(value = "/getMain")
    public String getMain(){
        return "app";
    }

    /**
     * 去往新增统计规则设置页面映射
     * @return
     */
    @RequestMapping(value = "/newAttendRule")
    public String newAttendRule(){
        return "app";
    }

    /**
     * 获取主页数据
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getAttendRule")
    public ToJson getAttendRule(){

        return attendRuleService.getAttendRule();
    }


    /**
     * 新增统计规则
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/insertAttendRule")
    public ToJson insertAttendRule(AttendRule attendRule){
        return attendRuleService.insertAttendRule(attendRule);
    }

    /**
     * 获取编辑数据
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getAttendRuleById")
    public ToJson getAttendRuleById(Integer id){

        return attendRuleService.getAttendRuleById(id);
    }

    /**
     * 编辑
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/updateAttendRule")
    public ToJson updateAttendRule(AttendRule attendRule){

        return attendRuleService.updateAttendRule(attendRule);
    }

    /**
     * 删除
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/deleteAttendRule")
    public ToJson deleteAttendRule(Integer id){

        return attendRuleService.deleteAttendRule(id);
    }
}
